<?php
/*
 *Delete id1 follow id2
 */
// authenticate user first
F3::call('authentication.php');
if (F3::exists('auth_error'))
{
  // authentication failed
  return;
}

$param = array('1'=>F3::get('SESSION.user_id'),'2'=>F3::get('PARAMS["user_id"]'));
$re = DB::sql("Select * from friends where id1 = ? and id2 = ?", $param);
if(count($re)==0){
	//we dont have id1 follow id2
	header('HTTP/1.1 403');
	header("Content-Type: application/json");
	$err = array("error_message" => "UseID1 doesnt follow UserID2", "1"=>F3::get('SESSION.user_id'), "2"=>F3::get('PARAMS["id"]'));
	echo json_encode($err);
	return;
}

$result = DB::sql("delete from friends where id1 = ? and id2 = ?", $param);

header('HTTP/1.1 204');

?>